<template>
  <div>
    <f-search-form :more='true' @searchHandler='searchHandler'>
      <f-search-form-item label='单号' name='paymentNo' />
      <f-search-form-item label='结算日期' type='range' name='beginDate' />
    </f-search-form>
    <f-table ref='table' size='small' rowKey='paymentId' :showSetting='false' setting-key='pay_payment_tab2' :tableColumns='columns' :scroll='{x:true}' :multiple='false' :operator='operator' :params='queryParam' :api='api.payment' handler='hySettleApplyTab2ListHandler'>
      <span slot='settleType' slot-scope='text, record, index'>
         <a-tag color='#87d068' v-if='text==1'>渠道商结算</a-tag>
         <a-tag color='#f47920' v-if='text==2'>商务经理结算</a-tag>
         <a-tag color='#8a5d19' v-if='text==3'>片区服务商结算</a-tag>
         <a-tag color='#7bbfea' v-if='text==4'>商务总负责人结算</a-tag>
      </span>
      <span slot='drugType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="ZY"'>自营</a-tag>
           <a-tag color='#FF0000' v-if='text=="ZS"'>招商</a-tag>
       </span>
      <span slot='taskName' slot-scope='text, record, index'>
        <a-tag color='purple' @click='processImg(record)'>{{ record.taskName }}</a-tag>
      </span>
      <span slot='action' slot-scope='text, record'>
          <template>
              <a href='javascript:;' @click="$refs['settleDetailsDrawer'].showDrawer(record,'form2')">明细</a>
          </template>
         <a-divider type='vertical' />
         <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
                <a-menu-item>
                <a href='javascript:;' @click='processImg(record)'>审批进度</a>
              </a-menu-item>
               <a-menu-item v-if='!record.paymentId'>
                <a href='javascript:;' @click='deleteProcessInstance(record.processInstanceId)'>清理数据</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
    </f-table>
    <process-image ref='processImg' v-if='processImageVisible' :visible.sync='processImageVisible' :processInstanceId='processInstanceId'></process-image>
    <settle-details-drawer ref='settleDetailsDrawer' @success='onLoad'></settle-details-drawer>
  </div>
</template>
<script>

import api from "../../js/api"
import ProcessImage from "../../../flowable/process/process_image"
import { processMixins } from "@/core/mixins/processMixins"
import SettleDetailsDrawer from "./components/settle_details_drawer"


export default {
  name: "TableList",
  components: {
    SettleDetailsDrawer,
    ProcessImage
  },
  mixins: [processMixins],
  data() {
    let me = this
    //操作按钮
    let operator = []

    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: { paymentState: 1 },
      processInstanceId: "",
      processImageVisible: false,
      // 表头
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "center",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "单号",
          align: "center",
          width: "130px",
          dataIndex: "paymentNo",
          scopedSlots: { customRender: "paymentNo" }
        },
        {
          title: "结算类型",
          align: "center",
          dataIndex: "settleType",
          width: "130px",
          scopedSlots: { customRender: "settleType" }
        },
        {
          title: "业务类型",
          align: "center",
          width: "80px",
          dataIndex: "drugType",
          scopedSlots: { customRender: "drugType" }
        },
        {
          title: "部门",
          align: "left",
          width: "80px",
          dataIndex: "deptName"
        },
        {
          title: "结算对象",
          align: "left",
          dataIndex: "payeeName",
          width: "100px"
        },
        {
          title: "业务编码",
          align: "left",
          width: "80px",
          dataIndex: "saleManCode"
        },
        {
          title: "申请金额",
          align: "center",
          dataIndex: "amount",
          width: "100px",
          needTotal: true
        },
        {
          title: "申请日期",
          align: "center",
          width: "100px",
          dataIndex: "amountDate"
        },

        {
          title: "申请人",
          align: "center",
          width: "100px",
          dataIndex: "nickName"
        },
        {
          title: "备注",
          align: "center",
          width: "200px",
          dataIndex: "remark"
        },
        {
          title: "创建日期",
          align: "center",
          width: "100px",
          dataIndex: "createTime"
        },
        {
          title: "审批状态",
          align: "left",
          width: "130px",
          dataIndex: "taskName",
          scopedSlots: { customRender: "taskName" }
        },
        {
          title: "操作",
          width: "130px",
          fixed: "right",
          align: "center",
          dataIndex: "action",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    onLoad() {
      this.$refs.table.refresh()
    },
    processImg(task) {
      this.processInstanceId = task.processInstanceId
      this.processImageVisible = true
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    }
  }
}
</script>
